package com.scvtc.controller.common;

import com.scvtc.domain.ResResult;
import com.scvtc.utils.MultipartFileUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Description: 文件上传
 * @Author: yiFei
 * @date: 2022/4/21 11:43
 */
@RestController
@Api(tags = "文件操作")
@RequestMapping("file")
public class MultipartFileController {

    @PostMapping("/upload")
    @ApiOperation("文件上传")
    public ResResult<?> fileUpload(@RequestParam("file") MultipartFile file, @RequestParam String dir) {
        return MultipartFileUtil.uploadFile(file, dir);
    }

    @DeleteMapping("/")
    @ApiOperation("文件删除")
    public void fileDelete(String path) {
        MultipartFileUtil.deleteFile(path);
    }
}
